<div class="wrapper wrapper-content" ng-controller="EquipmentMasterController">
	<div class="row">
		<div class="col-lg-12">
			<div class="tabs-container">
				<uib-tabset>
					<uib-tab heading="{{'COMMON.EQUIPMENT' | translate}}">
						<div class="panel-body" ng-controller="EquipmentController">
							<a ng-click="addEquipment()" class="btn btn-primary btn-rounded  btn-outline" href=""><i class="fa fa-plus-circle"></i> {{'EQUIPMENT.ADD_EQUIPMENT' | translate}}</a>
							<a ng-click="importEquipment()" class="btn btn-primary btn-rounded  btn-outline" href=""><i class="fa fa-plus-circle"></i> {{'SETTING.IMPORT' | translate}}</a>
							<table class="footable table table-bordered table-hover" data-sort="true" data-page-size="15">
								<thead>
									<tr>
										<th class="text-center" data-type="numeric">{{'SETTING.ID' | translate}}</th>
										<th class="text-center">{{'SETTING.NAME' | translate}}</th>
										<th class="text-center">{{'SETTING.IS_INPUT_COUNTED' | translate}}</th>
										<th class="text-center">{{'SETTING.IS_OUTPUT_COUNTED' | translate}}</th>
										<th class="text-center">{{'SETTING.DESCRIPTION' | translate}} ({{'SETTING.OPTIONAL' | translate}})</th>
										<th class="text-center">{{'SETTING.ACTION' | translate}}</th>
									</tr>
								</thead>
								<tbody>
									<tr ng-repeat="equipment in equipments">
										<td class="text-center">{{ equipment.id }}</td>
										<td class="text-center">{{ equipment.name }}</td>
										<td class="text-center">{{ equipment.is_input_counted==false?'SETTING.NO':'SETTING.YES' | translate }}</td>
										<td class="text-center">{{ equipment.is_output_counted==false?'SETTING.NO':'SETTING.YES' | translate }}</td>
										<td class="text-center">{{ equipment.description }}</td>
										<td class="text-center">
											<a ng-click="editEquipment(equipment)" class="btn btn-primary btn-rounded btn-xs" >{{'SETTING.EDIT' | translate}}</a>
											<a ng-click="deleteEquipment(equipment)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
											<a ng-click="exportEquipment(equipment)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.EXPORT' | translate}}</a>
											<a ng-click="cloneEquipment(equipment)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.CLONE' | translate}}</a>
										</td>
									</tr>
								</tbody>
								<tfoot class="hide-if-no-paging">
									<tr>
										<td colspan="6">
											<ul class="pagination pull-right"></ul>
										</td>
									</tr>
								</tfoot>
							</table>
						</div>
					</uib-tab>
					<uib-tab heading="{{'SETTING.BIND_METER' | translate}}">
						<div class="panel-body" ng-controller="EquipmentMeterController">
							<div class="row">
								<div class="col-lg-3">
									<div class="panel panel-info">
										<div class="panel-heading">
											{{'COMMON.EQUIPMENT' | translate}}
										</div>
										<div class="panel-body" >
											<form role="form">
												<div class="form-group no-margin"><label>{{'EQUIPMENT.SELECT_EQUIPMENT' | translate}}</label>
													<ui-select  on-select="changeEquipment($item,$model)" ng-model="currentEquipment.selected" theme="bootstrap">
														<ui-select-match placeholder="{{'COMMON.PLACEHOLDER' | translate}}">{{$select.selected.name}}</ui-select-match>
														<ui-select-choices repeat="equipment.id as equipment in equipments | filter: $select.search">
															<div ng-bind-html="equipment.name | highlight: $select.search"></div>
														</ui-select-choices>
													</ui-select>
												</div>
											</form>
										</div>
									</div>
								</div>
								<div class="col-lg-4">
									<div class="panel panel-primary">
										<div class="panel-heading">
											{{currentEquipment.name}}{{'SETTING.N_S_METER' | translate}}
										</div>
										<div class="panel-body maxheight"
									        x-hjc-drop-target="true"
										    x-on-drop="pairMeter(dragEl,dropEl)"
										    uib-tooltip="{{'SETTING.DRAG_TO_UNBIND' | translate}}" >

										<div class="btn btn-rounded btn-block"
										ng-class="colorMeterType(equipmentmeter.metertype)"
										ng-repeat="equipmentmeter in equipmentmeters"
										x-hjc-draggable="true"
										title="{{equipmentmeter.metertype}}|output:{{equipmentmeter.is_output}}">({{equipmentmeter.energy_category.name}}){{equipmentmeter.name}}</div>
									</div>
								</div>
								<div class="panel panel-danger">
									<div class="panel-heading">
										{{'SETTING.TRASH' | translate}}
									</div>
									<div class="panel-body trash" >
										<img class="trashcan"
										src="img/trashcan.png"
										x-hjc-drop-target="true"
										x-on-drop="deleteMeterPair(dragEl,dropEl)">
									</div>
								</div>
							</div>

							<div class="col-lg-4">
								<!-- according panel-->
								<div class="panel panel-primary">
									<div class="panel-heading">
										{{'SETTING.METER' | translate}}
									</div>
									<div class="panel-body" uib-tooltip="{{'SETTING.DRAG_TO_BIND' | translate}}"
									slim-scroll box-height="765px">
										<div class="form-group no-margin"><label>{{'SETTING.METER_TYPE' | translate}}</label>
											<select ng-change="changeMeterType()"  ng-model="currentMeterType" class="form-control m-b" name="metertype">
												<option value="meters">{{'SETTING.METER' | translate}}</option>
												<option value="virtualmeters">{{'SETTING.VIRTUAL_METER' | translate}}</option>
												<option value="offlinemeters">{{'SETTING.OFFLINE_METER' | translate}}</option>
											</select>
										</div>
										<div class="source btn btn-primary btn-rounded btn-block"
										ng-repeat="meter in currentmeters"
										x-hjc-draggable="true"
										ng-class="colorMeterType(currentMeterType)"
										> ({{meter.energy_category.name}}){{meter.name}}</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				  </uib-tab>
					<uib-tab heading="{{'EQUIPMENT.BIND_PARAMETER' | translate}}">
						<div class="panel-body" ng-controller="EquipmentParameterController">
							<div class="row">
								<div class="col-lg-3">
									<div class="panel panel-info">
										<div class="panel-heading">
											{{'COMMON.EQUIPMENT' | translate}}
										</div>
										<div class="panel-body" >
											<form role="form">
												<div class="form-group no-margin"><label>{{'EQUIPMENT.SELECT_EQUIPMENT' | translate}}</label>
													<ui-select  on-select="changeEquipment($item,$model)" ng-model="currentEquipment.selected" theme="bootstrap">
														<ui-select-match placeholder="{{'COMMON.PLACEHOLDER' | translate}}">{{$select.selected.name}}</ui-select-match>
														<ui-select-choices repeat="equipment.id as equipment in equipments | filter: $select.search">
															<div ng-bind-html="equipment.name | highlight: $select.search"></div>
														</ui-select-choices>
													</ui-select>
												</div>
											</form>
										</div>
									</div>
								</div>
								<div class="col-lg-9">
									<div class="panel panel-primary">
										<div class="panel-heading">
											{{currentEquipment.name}}{{'EQUIPMENT.N_S_PARAMETER' | translate}}
										</div>
										<div class="panel-body" >
											<a ng-show="is_show_add_parameter" ng-click="addEquipmentParameter()" class="btn btn-primary btn-rounded  btn-outline" href=""><i class="fa fa-plus-circle"></i> {{'EQUIPMENT.ADD_PARAMETER' | translate}}</a>
											<table class="footable table table-bordered table-hover" data-sort="true" data-page-size="15">
												<thead>
													<tr>
														<th class="text-center" data-type="numeric">{{'EQUIPMENT.PARAMETER_ID' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_NAME' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_TYPE' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_CONSTANT' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_POINT' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_NUMERATOR_METER' | translate}}</th>
														<th class="text-center">{{'EQUIPMENT.PARAMETER_DENOMINATOR_METER' | translate}}</th>
														<th class="text-center">{{'SETTING.ACTION' | translate}}</th>
													</tr>
												</thead>
												<tbody>
													<tr ng-repeat="equipmentparameter in equipmentparameters">
														<td class="text-center">{{ equipmentparameter.id }}</td>
														<td class="text-center">{{ equipmentparameter.name }}</td>
														<td class="text-center">{{ showEquipmentParameterType(equipmentparameter.parameter_type) | translate }}</td>
														<td class="text-center">{{ equipmentparameter.parameter_type == 'constant' ? equipmentparameter.constant : '-' }}</td>
														<td class="text-center">{{ equipmentparameter.parameter_type == 'point' ?  equipmentparameter.point.name : '-' }}</td>
														<td class="text-center">{{ showEquipmentParameterNumerator(equipmentparameter) }}</td>
														<td class="text-center">{{ showEquipmentParameterDenominator(equipmentparameter) }}</td>
														<td class="text-center">
															<a class="btn btn-primary btn-rounded btn-xs" ng-click="editEquipmentParameter(equipmentparameter)" >{{'SETTING.EDIT' | translate}}</a>
															<a ng-click="deleteEquipmentParameter(equipmentparameter)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>

														</td>
													</tr>
												</tbody>
												<tfoot class="hide-if-no-paging">
													<tr>
														<td colspan="6">
															<ul class="pagination pull-right"></ul>
														</td>
													</tr>
												</tfoot>
											</table>
									</div>
								</div>
							  </div>
						</div>
					</div>
				  </uib-tab>
					<uib-tab heading="{{'SETTING.BIND_COMMAND' | translate}}">
						<div class="panel-body" ng-controller="EquipmentCommandController">
							<div class="row">
								<div class="col-lg-3">
									<div class="panel panel-info">
										<div class="panel-heading">
											{{'COMMON.EQUIPMENT' | translate}}
										</div>
										<div class="panel-body" slim-scroll box-height="600px">
											<form role="form">
												<div class="form-group no-margin">
													<label>{{'EQUIPMENT.SELECT_EQUIPMENT' | translate}}</label>
													<ui-select on-select="changeEquipment($item,$model)"
														ng-model="currentEquipment.selected" theme="bootstrap">
														<ui-select-match
															placeholder="{{'COMMON.PLACEHOLDER' | translate}}">
															{{$select.selected.name}}</ui-select-match>
														<ui-select-choices
															repeat="equipment.id as equipment in equipments | filter: $select.search">
															<div ng-bind-html="equipment.name | highlight: $select.search">
															</div>
														</ui-select-choices>
													</ui-select>
												</div>
											</form>
										</div>
									</div>

								</div>

								<div class="col-lg-4">
									<div class="panel panel-primary">
										<div class="panel-heading">
											{{'SETTING.N_S_COMMAND' | translate}}
										</div>
										<div class="panel-body maxheight"
											x-hjc-drop-target="true"
											x-on-drop="pairCommand(dragEl,dropEl)"
											uib-tooltip="{{'SETTING.DRAG_TO_UNBIND' | translate}}">
											<div class="btn btn-primary btn-rounded btn-block"
												ng-repeat="equipmentcommand in equipmentcommands" x-hjc-draggable="true"
												title="{{equipmentcommand.name}}">
												{{equipmentcommand.name}}</div>
										</div>
									</div>
									<div class="panel panel-danger">
										<div class="panel-heading">
											{{'SETTING.TRASH' | translate}}
										</div>
										<div class="panel-body trash">
											<img class="trashcan" src="img/trashcan.png" x-hjc-drop-target="true"
												x-on-drop="deleteCommandPair(dragEl,dropEl)">
										</div>

									</div>
								</div>

								<div class="col-lg-4">
									<!-- according panel-->
									<div class="panel panel-primary">
										<div class="panel-heading">
											{{'SETTING.COMMAND_LIST' | translate}}
										</div>
										<div class="panel-body" uib-tooltip="{{'SETTING.DRAG_TO_BIND' | translate}}"
											slim-scroll box-height="765px">
											<div class="source btn btn-primary btn-rounded btn-block"
												ng-repeat="command in commands" x-hjc-draggable="true">
												{{command.name}}</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</uib-tab>
		</uib-tabset>
	</div>
</div>
</div>
</div>
